-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------

-- Your code here


-- Add libs
json = require( "json" )
widget = require( "widget" )
composer = require( "composer" )
SCREEN_W = display.getCurrentStage().width
SCREEN_H = display.getCurrentStage().height
--display.setDrawMode( "wireframe", false )
SCREEN_MW = SCREEN_W / 2
SCREEN_MH = SCREEN_H / 2

display.setStatusBar( display.HiddenStatusBar)

common = require("lib.common")
sceneM = require("lib.sceneM")

-- 自定义管理类
animate = require("lib.animations")
Music = require("lib.music")
sceneManage = require("lib.SceneManage")
-- 读取配置表
configManager = require "config.configManager"

-- 全局函数
require "lib.globalFunc"
-- require("lib.playerM")

-- 网络模块
-- socketManager = require("script.socketManager")

-- 全局监听
Runtime:addEventListener( "system", function( event )
end )


local function test()
    Music.play{musicStr = "main", index = 1}
	-- 精灵动画创建 方式一 压缩文件式
	local sheet1 = require("assets.sprite.sheet_1")
	local sheetData =  sheet1:getSheet()
	local imgStr = "assets/sprite/sprite_1.png"
	local imgSheet = graphics.newImageSheet(imgStr, sheetData)
	local sequenceData = {             
        {name = "MOVE", frames= sheet1:getFrames("M") , time = 600, loopCount = 0},  
        {name = "ATTACK", frames = sheet1:getFrameIndexs{"A1", "A2", "A3", "A4", "A5", "A5"},time = 600,loopCount = 1},   
       	{name = "WAIT", frames = sheet1:getFrames("W"), time = 800, loopCount = 2},
       	{name = "DEAD", frames = sheet1:getFrames("D"), time = 800, loopCount = 1},
       	{name = "INJURED", frames = {sheet1:getFrameIndex("I")}, time = 400, loopCount = 1},             
       	{name = "HITFLY", frames ={sheet1:getFrameIndex("I")}, time = 400, loopCount = 0},             
       	{name = "STAND", frames = sheet1:getFrames("W"), time = 800, loopCount = 0},
   	}
	local sprite = display.newSprite(imgSheet, sequenceData)
	sprite.x = 200
	sprite.y = 200
	sprite:setSequence("WAIT")
	--sprite:setSequence("ATTACK")
	sprite:play()


	-- 方式二
	local sheetData = {width = 340 / 2, height = 139, numFrames = 2}
	local imgSheet = graphics.newImageSheet("assets/sprite/sprite_2.png", sheetData)
	local sprite = display.newSprite(imgSheet, {start = 1, count = 2, time = 300})
	sprite.x = 200
	sprite.y = 300
	sprite:play()
end	
-- test()

physics = require "physics"

physics.start()

composer.gotoScene( "scene.testScene" )
